﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

//buddy
using Zeta;
using Zeta.Common;
using Zeta.CommonBot;
using Zeta.Common.Plugins;
using Zeta.Internals;
using Zeta.Internals.Actors;
using Zeta.Internals.Service;

namespace BossHog.ProfileBuilder
{    
    public interface IProfileChildElement 
    {
        void Write(System.Xml.XmlTextWriter w);
    }

    public class ProfileElement
    {
        public ProfileElement() { Commands = new List<IProfileChildElement>(); }
        public List<IProfileChildElement> Commands { get; set; }
        public override string ToString()
        {

            if (null == Commands || Commands.Count < 1) return "<Profile></Profile>";

            StringBuilder tmp = new StringBuilder();
            tmp.AppendLine("<Profile>");
            for (int i = 0; i < Commands.Count; i++)
            {
                tmp.AppendLine(Commands[i].ToString());
            }
            tmp.AppendLine("</Profile>");
            return tmp.ToString();
        }

        public void Write(System.Xml.XmlTextWriter w)
        {
            Type t = this.GetType();
            w.WriteStartElement("Profile");
            if (null != Commands && Commands.Count > 0)
            {
                for (int i = 0; i < Commands.Count; i++)
                {
                    Commands[i].Write(w);
                }
            }
            w.WriteEndElement();
        }

    }

}
